package com.fulihui.weixinsdk.request;

import com.alibaba.fastjson.JSON;
import com.fulihui.weixinsdk.http.HttpMethodEnum;
import com.fulihui.weixinsdk.result.ComponentAccessTokenResult;
import com.google.gson.Gson;
import lombok.Data;

/**
 * 第三方平台通过自己的component_appid（即在微信开放平
 * 台管理中心的第三方平台详情页中的AppID和AppSecret）和
 * component_appsecret，以及component_verify_ticket（每
 * 10分钟推送一次的安全ticket）来获取自己的接口调用凭据（component_access_token）
 *
 * Created by LeeSon on 2017/3/30 0030.
 */
@Data
public class ComponentAccessTokenRequest extends WeixinRequest<ComponentAccessTokenResult> {
    private String component_appid;
    private String component_appsecret;
    private String component_verify_ticket;

    @Override
    protected void childParam() {

    }

    @Override
    public String service() {
        return "https://api.weixin.qq.com/cgi-bin/component/api_component_token";
    }

    @Override
    public String urlEndStr() {
        return null;
    }

    @Override
    public ComponentAccessTokenResult parseResult(String respStr) {
        return new Gson().fromJson(respStr, ComponentAccessTokenResult.class);
    }

    @Override
    public HttpMethodEnum httpMethod() {
        return HttpMethodEnum.POST;
    }

    @Override
    public String requestData() {
        return JSON.toJSONString(this);
    }
}
